package com.shievy.anweb.base.uitl

import android.util.Log
import com.shievy.anweb.base.BuildConfig


object LogUtil {

    enum class Level {
        INFO, ERROR, DEBUG, V
    }

    fun i(TAG: String = "LogUtil", msg: Any?) {
        log(TAG, msg, Level.INFO)
    }

    fun d(TAG: String = "LogUtil", msg: Any?) {
        log(TAG, msg, Level.DEBUG)
    }

    fun e(TAG: String = "LogUtil", msg: Any?) {
        log(TAG, msg, Level.ERROR)
    }

    fun v(TAG: String = "LogUtil", msg: Any?) {
        log(TAG, msg, Level.V)
    }

     fun log(TAG: String, msg: Any?, level: Level) {
        if (BuildConfig.DEBUG) {
            when (level) {
                Level.INFO -> Log.i(TAG, "$msg")
                Level.ERROR -> Log.e(TAG, "$msg")
                Level.DEBUG -> Log.d(TAG, "$msg")
                Level.V -> Log.v(TAG, "$msg")
                else -> Log.w(TAG, "$msg")
            }
        }

    }
}